home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / communic / litecomm / lxm.doc < prev    next >
Encoding:
Text File  |  1993-03-14  |  35.4 KB  |  1,123 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.                                   INTRODUCING LXM
  10.                                   INTRODUCING LXM
  11.                                   _______________
  12.  
  13.  
  14.             BRIEF HISTORY OF XMODEM
  15.             BRIEF HISTORY OF XMODEM
  16.             _______________________
  17.  
  18.  
  19.             During the glory days of CP/M, the computer industry was
  20.             plagued with a plethora of diskette formats. Since there was
  21.             no single standard around, particularly when the 5" format
  22.             was introduced, data interchange between computers was
  23.             difficult.
  24.  
  25.  
  26.             Several manufacturers attempted to provide a solution by
  27.             giving their users the ability to at least read multiple
  28.             diskette formats. Rather than promoting a standard format,
  29.             this approach encouraged manufacturers to adopt proprietary
  30.             formats as a marketing tool. Partially as a response to this
  31.             situation, and partially out of a need to provide data
  32.             transmission capabilities, Ward Christiansen developed the
  33.             original specification for the XModem file transfer
  34.             protocol.
  35.  
  36.  
  37.             The XModem protocol, elegant in its simplicity and
  38.             effectiveness, has transcended the decline of CP/M-based
  39.             systems, and the ascendency of MS-DOS to become a de facto
  40.             standard for data transfer between remote computers. This
  41.             fact is true, even in the light of the near-universal
  42.             acceptance of another de facto standard for diskette
  43.             formats, as popularized by the IBM-PC family. With the
  44.             advent of the new PS/2 with its incompatible micro-
  45.             diskettes, the XModem protocol's place, at least for the
  46.             foreseeable future, seems assured.
  47.  
  48.  
  49.  
  50.                                PROTOCOL FUNDAMENTALS
  51.                                PROTOCOL FUNDAMENTALS
  52.                                _____________________
  53.  
  54.  
  55.             THE TRANSMISSION BLOCK
  56.             THE TRANSMISSION BLOCK
  57.             ______________________
  58.  
  59.  
  60.             The fundamental building block of XModem is an 8-bit byte,
  61.             no parity please, arranged into transmission blocks of
  62.             exactly 132 characters, never more nor less. In one
  63.             extension to XModem, commonly called CRC-XModem, the
  64.             transmission blocks are exactly 133 characters. We will
  65.             discuss this extension , and a second known as YModem,
  66.             later.
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  79.                                Datalight and Turbo C
  80.  
  81.             As you might guess, not only is the length of a transmission
  82.             block fixed, but so too is the format. The XModem block
  83.             format looks like this:
  84.  
  85.  
  86.                 <SOH> <REC> <~REC> <...128 Data Bytes...> <checksum>
  87.  
  88.             
  89.  
  90.             where:
  91.             
  92.                  SOH - 0x01 Signals the start of a block
  93.                  REC - Is the sequential block number reduced modulo 256
  94.                  ~REC - The ones-compliment of REC
  95.                  checksum - an 8-bit sum of the preceding 128 data
  96.                       bytes, formed by adding each byte to an
  97.                       accumulator, then dropping all but the low order 8
  98.                       bits of the result.
  99.  
  100.  
  101.             The intent of the additional characters is to facilitate
  102.             error checking and recovery, making the XModem protocol an
  103.             "error-free" means of data transfers under otherwise hostile
  104.             conditions.
  105.  
  106.  
  107.             The block number and its compliment are included to insure
  108.             that no blocks are accidentally lost during transmission,
  109.             and to prevent the accidental duplication of a data block
  110.             which might be caused by spurious line noise. The checksum
  111.             seeks to insure the validity of the actual data which might
  112.             become garbled by line noise. The fixed length block format
  113.             tends to simplify the logic required to implement the
  114.             protocol in the first place.
  115.  
  116.  
  117.  
  118.             THE INTER-COMPUTER DIALOG
  119.             THE INTER-COMPUTER DIALOG
  120.             _________________________
  121.  
  122.  
  123.             Xmodem is essentially uni-directional in nature. That is,
  124.             the actual flow of meaningful information occurs in one
  125.             direction at a time, from the sending computer to the
  126.             receiving computer. This is not meant to imply, however,
  127.             that only one computer sends and the computer receives. To
  128.             the contrary, there is a constant "dialog" going on between
  129.             the two computers during the course of the transmission. It
  130.             is this dialog that permits XModem to be true, "error-free"
  131.             transfer method.
  132.  
  133.  
  134.  
  135.  
  136.  
  137.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  147.                                Datalight and Turbo C
  148.  
  149.             Xmodem is a receiver-driven protocol. The receiving computer
  150.             initiates and almost exclusively controls the transmissions,
  151.             through a series of pre-planned responses. A typical, though
  152.             brief dialog might look like this:
  153.  
  154.  
  155.                  RECEIVER            SENDER            MEANING
  156.                  ________            ______            _______
  157.             
  158.                   <NAK>         -------------->    READY TO RECEIVE
  159.               <-------------        <BLOCK1>       FIRST BLOCK SENT
  160.                   <ACK>         -------------->   BLOCK RECEIVED OK
  161.               <-------------        <BLOCK2>         SECOND BLOCK
  162.                   <NAK>         -------------->     ERROR, RESEND
  163.               <-------------        <BLOCK2>         SECOND BLOCK
  164.                   <ACK>         -------------->   BLOCK RECEIVED OK
  165.               <-------------         <EOT>           END OF FILE
  166.                   <ACK>         -------------->    E-O-F UNDERSTOOD
  167.  
  168.  
  169.             As you can see, it is through the responses to the sending
  170.             computer that the receiver controls the link.
  171.  
  172.  
  173.             Xmodem also makes provision for unusual circumstances by
  174.             providing both time-out and cancellation mechanisms. The
  175.             rules for time-outs, time periods which may elapse before a
  176.             disruption in transmission occurs are as follows:
  177.  
  178.  
  179.  
  180.                 1. Waiting for SOH - 10 seconds, Resend last
  181.                    acknowledgement on time-out.
  182.  
  183.  
  184.                 2. Waiting for other block characters - 1 second,
  185.                    replace expected character with some pre-defined
  186.                    value upon time-out.
  187.  
  188.  
  189.                 3. Waiting for a reply to a block - 10 seconds,
  190.                    Resend last block upon time-out.
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  214.                                Datalight and Turbo C
  215.  
  216.             The original protocol description also makes it possible for
  217.             either the sender or receiver to cancel the transmission.
  218.             This is of particular value when too many transmission
  219.             errors occur, or, in rare cases, when the physical
  220.             connection is broken. The threshold beyond which either side
  221.             may request cancellation, although specified as 10 attempts
  222.             in the original description of the protocol, has become
  223.             somewhat arbitrary over time. The cancellation code, <CAN>
  224.             or 0x10, may be sent by either the sender or receiver in
  225.             place of the <SOH> or normal acknowledgment character
  226.             respectively.
  227.  
  228.  
  229.  
  230.             ENHANCEMENTS TO XMODEM
  231.             ENHANCEMENTS TO XMODEM
  232.             ______________________
  233.  
  234.  
  235.             Over the years, several significant enhancements have been
  236.             made to the protocol as originally defined by Ward
  237.             Christiansen. The intent of these enhancements have
  238.             generally been to improve upon the error-handling capability
  239.             of the protocol, and to make the protocol more amenable to
  240.             some less time-efficient communications environments,
  241.             particularly those presented by for-pay services such as
  242.             CompuServe.
  243.  
  244.  
  245.             To make the protocol more error-free, the checksum employed
  246.             in the original design has been replaced by a 16 bit
  247.             calculation, called a Cyclical Redundancy Check or CRC.
  248.             Based upon a polynomial equation, the CRC method can be
  249.             mathematically demonstrated to be sensitive to all but about
  250.             .03 per cent of errors. This error detection rate, about
  251.             99.97 percent accurate, is far superior to the approximately
  252.             90 to 92 percent accuracy of the checksum approach. The
  253.             overhead of an additional 8 bits per message seems to make
  254.             this enhancement well worth while.
  255.  
  256.  
  257.             The second enhancement seeks to improve communication over
  258.             packet-switched networks, like those employed by CompuServe
  259.             and other national services. Basically this enhancement
  260.             introduces a relaxed time-out between characters in a block,
  261.             allowing additional time before the protocol recognizes a
  262.             time-out condition.
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  282.                                Datalight and Turbo C
  283.  
  284.             A third enhancement, variant of the original XModem protocol
  285.             seeks to improve overall efficiency by expanding the block
  286.             size from 128 characters to 1024 characters.  This variant,
  287.             commonly call ymodem, reduces the number of times that an
  288.             acknowledgment sequence must be sent, thereby increasing the
  289.             efficiency of actual data transfer.
  290.  
  291.  
  292.             The LXM XModem engine supports all of the enhancements
  293.             mentioned above.
  294.  
  295.  
  296.  
  297.                                    THE LXM ENGINE
  298.                                    THE LXM ENGINE
  299.                                    ______________
  300.  
  301.  
  302.             OVERVIEW
  303.             OVERVIEW
  304.             ________
  305.  
  306.  
  307.             One of the reasons for the popularity of the XModem protocol
  308.             over time is the simplicity of the implementation. Given a
  309.             reasonable communications package upon which to build,
  310.             developing a basic implementation of XModem is relatively
  311.             simple, although under certain operating systems, such as
  312.             the Unix family, the attempt of the OS to be all things to
  313.             all people may actually become an impediment.
  314.  
  315.  
  316.             The intent of the LXM engine is to 1) provide XModem
  317.             capability, 2) in a flexible, easy to understand package, 3)
  318.             built upon a sound foundation, the LiteComm communications
  319.             ToolBox. Because of the manner in which the LXM engine was
  320.             designed virtually any application can have access to
  321.             XModem's error-free protocol, without being relegated to
  322.             simply transferring files.
  323.  
  324.  
  325.  
  326.             MAJOR ENGINE COMPONENTS
  327.             MAJOR ENGINE COMPONENTS
  328.             _______________________
  329.  
  330.  
  331.             The LXM engine consists, primarily of two functions, lcxrrec
  332.             and lcxtrec, receive a record and transmit a record
  333.             respectively. Because these two functions 'understand' the
  334.             XModem protocol internally, they assume full responsibility
  335.             for all of the necessary housekeeping, relying upon the host
  336.             program for only the most basic of functions.
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  354.                                Datalight and Turbo C
  355.  
  356.             The lcxrrec function receives one or more records from a
  357.             companion system. The host program controls the checking
  358.             method, CRC or checksum, the time-out method, normal or
  359.             relaxed, handles, in what ever way appropriate, blocks of
  360.             data that have been received, and can optionally monitor the
  361.             flow of data from the companion system. Lcxrrec assumes the
  362.             responsibility for synchronizing with the companion system
  363.             and for correctly maintaining the flow of information.
  364.  
  365.  
  366.             Lcxtrec performs in a like fashion when the host program
  367.             wants to send one or more records. The host program has only
  368.             to present the record to be transmitted, and lcxtrec does
  369.             the rest. The lcxtrec module assumes responsibility for
  370.             establishing synchronization with the receiving computer,
  371.             and for recognizing the checking method, CRC or checksum,
  372.             that the receiver wants to use. Lcxtrec also terminates the
  373.             transmission, when told to do so by the host program, and
  374.             permits the host to optionally monitor the data flow.
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  420.                                Datalight and Turbo C
  421.  
  422.                                  NOTES AND WARNINGS
  423.                                  NOTES AND WARNINGS
  424.                                  __________________
  425.  
  426.  
  427.             MODIFICATIONS
  428.             MODIFICATIONS
  429.             _____________
  430.  
  431.  
  432.             The LXM engine is closely integrated with the LiteComm
  433.             ToolBox. While there is every likelihood that the engine can
  434.             be modified to function with other similar packages,
  435.             Information Technology, Ltd., can only support the LXM
  436.             engine when used with either the LiteComm ToolBox.
  437.  
  438.  
  439.  
  440.             PARITY AND DATA BITS
  441.             PARITY AND DATA BITS
  442.             ____________________
  443.  
  444.  
  445.             The XModem protocol is an 8-bit protocol. That is to say it
  446.             neither recognizes nor tolerates parity checking, i.e. 7
  447.             data bits plus a specified parity. Since the LXM engine
  448.             cannot determine the current settings for parity and number
  449.             of data bits, the responsibility for controlling these
  450.             settings rests with the host program. Before using either of
  451.             the key functions lcxrrec or lcxtrec, the host program must
  452.             insure that the settings are no parity, 8 data bits, using
  453.             the comm_setup function. Upon final termination of the
  454.             function, the host program must reset these values to their
  455.             original settings, if necessary.
  456.  
  457.  
  458.  
  459.             INTERNAL TIMER FUNCTION
  460.             INTERNAL TIMER FUNCTION
  461.             _______________________
  462.  
  463.  
  464.             Both lcxrrec and lcxtrec employ a hardware-based timing
  465.             function that connects directly to the normal real-time
  466.             clock vector 0x1C; The Microsoft and Turbo C version of this
  467.             function also establishes an special routine, using the
  468.             atexit() function, to insure that this vector is re-
  469.             established at is original setting when program termination
  470.             occurs. This is not true of the Datalight version however.
  471.             The Datalight library does not, at present, have an like
  472.             atexit().
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482.  
  483.  
  484.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  494.                                Datalight and Turbo C
  495.  
  496.             While every effort has been made, for Datalight users, to
  497.             insure that the vector is properly reset, this plan may be
  498.             thwarted by abnormal termination of the host program
  499.             resulting in a subsequent system crash. The safest method to
  500.             Datalight user's to employ would be to use the lc_clrclock()
  501.             function before host program termination. As an alternate
  502.             approach, Datalight users may want to investigate STEVE'S
  503.             LIBRARY designed for Datalight C users's. This excellent
  504.             library does have an equivalent function to the atexit().
  505.  
  506.  
  507.  
  508.             BUFFER SIZE RESTRICTION
  509.             BUFFER SIZE RESTRICTION
  510.             _______________________
  511.  
  512.  
  513.             The LiteComm ToolBox permits you a great deal of freedom in
  514.             tailoring the communications handler to meet your specific
  515.             requirements. We must caution you, however, that when you
  516.             are using the LXM engine, the minimum buffer sizes required
  517.             by the comm_opn function are not adequate to support LXM,
  518.             particularly when transmitting records at either low baud
  519.             rates, or on the new generation of high-speed (above 6 MHz)
  520.             processors.
  521.  
  522.  
  523.             During the development of LXM, it was quickly discovered
  524.             that too small a transmit buffer quickly resulted in a
  525.             buffer overflow condition. We recommend that, when using the
  526.             LXM engine, the transmit buffer be set at a minimum 256
  527.             bytes to avoid the overflow condition.  If you intended to
  528.             employ the YModem variant, then the minimum buffer sizes
  529.             should be set to at least 1030.
  530.  
  531.  
  532.  
  533.             XON-XOFF CONTROL
  534.             XON-XOFF CONTROL
  535.             ________________
  536.  
  537.  
  538.             If your host program employs the XON-XOFF functions in
  539.             LiteComm, you must be sure that the automatic XON-XOFF
  540.             handing is disabled before you attempt to transmit or
  541.             receive records using LXM. Failure to observe this caution
  542.             may result in a system hang, requiring that the system be
  543.             re-booted.
  544.  
  545.  
  546.  
  547.             USER-ACCESSIBLE DATA
  548.             USER-ACCESSIBLE DATA
  549.             ____________________
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  566.                                Datalight and Turbo C
  567.  
  568.             Within LXM, certain variables have been defined as being
  569.             globally available. The host program may examine the
  570.             contents of these variables at any time to determine the
  571.             current state of the LXM engine. The correct definitions of
  572.             these variable is contained in litexm.h. Except as noted
  573.             below, the host program must NOT alter the contents of these
  574.             variables.
  575.  
  576.  
  577.  
  578.                 abort_flag - This is the only variable of the group
  579.                 __________                                         
  580.                    that may be altered by the host program. The
  581.                    flag is checked periodically by the engine
  582.                    functions. If _abort_flag has a value of 1, the
  583.                    function in progress will be cancelled
  584.                    automatically by sending a CAN instruction to
  585.                    the companion system. See the TTL.C sample
  586.                    program for an example of how this flag may be
  587.                    set.
  588.  
  589.  
  590.                 crc   - If this variable has a non-zero value, then
  591.                 ___                                                
  592.                    the LXM engine is currently using the CRC error-
  593.                    checking method. A zero value indicates that the
  594.                    original checksum method is being used.
  595.  
  596.  
  597.                 checksum and crcaccum-These variables hold the
  598.                 _____________________                         
  599.                    current/last calculated check value. In a
  600.                    practical sense, they are of no value to the
  601.                    host program.
  602.  
  603.  
  604.                 rec   - This variable contains the current record
  605.                 ___                                              
  606.                    (block) number being processed. In the event of
  607.                    an uncorrectable error, rec would contain the
  608.                    number of the expected block. In the case of a
  609.                    successful transmission or reception, rec-1 is
  610.                    the number of the block sent or received. The
  611.                    value contained in this variable, reduced modulo
  612.                    256, provides the block number required by the
  613.                    XModem protocol and must NEVER be disturbed.
  614.  
  615.  
  616.                 ymodem     - This variable is set to TRUE if the
  617.                 ______                                          
  618.                    host application wants to transmit a block in
  619.                    YModem mode (1024 characters). See the
  620.                    discussion of lcxtrec, below.
  621.  
  622.  
  623.                                PROGRAMMERS REFERENCE
  624.                                PROGRAMMERS REFERENCE
  625.                                _____________________
  626.  
  627.  
  628.  
  629.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  639.                                Datalight and Turbo C
  640.  
  641.             ENGINE-RELATED FUNCTIONS
  642.             ENGINE-RELATED FUNCTIONS
  643.             ________________________
  644.  
  645.  
  646.             The following pages document the LXM engine functions as
  647.             currently implemented.  They follow, in style and content,
  648.             the documentation for the LiteComm ToolBox itself.
  649.  
  650.  
  651.             Use the following pages as an addendum to your LiteComm
  652.             documentation.
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  707.                                Datalight and Turbo C
  708.  
  709.            _______________________________________________________________
  710.  
  711.                                       lcxrrec
  712.            _______________________________________________________________
  713.  
  714.  
  715.             SUMMARY
  716.             SUMMARY
  717.             _______
  718.  
  719.                  #include <litexm.h>
  720.                  #include <litecomm.h>
  721.                  
  722.                  int lcxrrec(port,buff,rbsize,hmode,hdshk)
  723.                       unsigned port;
  724.                       unsigned char *buff;
  725.                       int *rbsize;
  726.                       int hmode;
  727.                       unsigned char *hdshk;
  728.  
  729.  
  730.             DESCRIPTION
  731.             DESCRIPTION
  732.             ___________
  733.  
  734.             Receive a block of either 128 or 1024 bytes from the
  735.             companion system, using the checking method specified in
  736.             hdshk, and the time-out value specified in hmode.  If
  737.             necessary, establish synchronization with the companion
  738.             system.
  739.  
  740.  
  741.             The port parameter is the same as used throughout the
  742.             LiteComm ToolBox.
  743.  
  744.  
  745.             Buff should be a pointer to an array of 128 bytes in when
  746.             using XModem mode, 1024 bytes for YModem mode.  All record
  747.             characters are received into this area, and, if the area is
  748.             too small, LXM will overwrite adjacent data without warning.
  749.  
  750.  
  751.             Rbsize is a POINTER to an integer variable.  Lcxrrec returns
  752.             the actual length of the received block to this variable.
  753.             This approach is needed since, using YModem, blocks may be
  754.             either 1024 bytes or 128 bytes at the discretion of the
  755.             SENDER.  Lcxrrec automatically detects the block length and
  756.             returns it to the caller so that the caller can process the
  757.             block correctly.
  758.  
  759.  
  760.             The value of hmode determines whether normal or relaxed
  761.             time-out values are used. Please use the constants provided
  762.             in the litexm header file to insure a proper setting.
  763.  
  764.             The value contained initially in hdshk must be either CRC or
  765.             NAK, defined in litexm.h. The former specifies the use of
  766.  
  767.  
  768.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  778.                                Datalight and Turbo C
  779.  
  780.             the 16 bit CRC checking mode, while the latter specifies the
  781.             use of the original checksum method.  Note - If you intend
  782.             to operate in YModem mode, hdshk must specify CRC.
  783.  
  784.             Note that hdshk is a pointer to a character. Lcxrrec uses
  785.             this area to store its reply to the last received block.
  786.             Once you have set this value, and have started to receive,
  787.             DO NOT alter its value under any circumstances. Doing so may
  788.             cause unpredictable results.
  789.  
  790.  
  791.  
  792.             EXAMPLE
  793.             EXAMPLE
  794.             _______
  795.  
  796.             See the accompanying program TTL for an example of lcxrrec
  797.             usage.
  798.  
  799.  
  800.  
  801.             RETURN VALUES
  802.             RETURN VALUES
  803.             _____________
  804.  
  805.             Lcxrrec may return several values, as defined in the
  806.             litexm.h file. Each return value should cause the host
  807.             program to respond in specific ways.
  808.  
  809.  
  810.             SUCCESS - A record has been successfully received into the
  811.             SUCCESS                                                   
  812.             buff area. Host program process the record and calls lcxrrec
  813.             again.
  814.  
  815.  
  816.             RETRIES - The maximum number of attempts to receive a single
  817.             RETRIES                                                     
  818.             record has been exceeded. Lcxrrec automatically cancels the
  819.             session. Host program should handle in an appropriate
  820.             manner, e.g. issue error message.
  821.  
  822.  
  823.             ERR (-1) - Lcxrrec has detected that the host program has
  824.             ERR                                                      
  825.             requested cancellation of transmissions through the
  826.             _abort_flag setting (see below) or a fatal record sequence
  827.             has occurred, e.g. a block number has been skipped. Lcxrrec
  828.             automatically cancels the session.
  829.  
  830.  
  831.             CAN - The sending program has requested cancellation. Host
  832.             CAN                                                       
  833.             program should handle in a fashion similar to RETRIES.
  834.  
  835.  
  836.             EOT - The sending program has no more data to transmit.
  837.             EOT                                                    
  838.             Lcxrrec acknowledges the EOT message automatically. Host
  839.             program handles like an end-of-file condition.
  840.  
  841.  
  842.  
  843.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  853.                                Datalight and Turbo C
  854.  
  855.             TOUT - Lcxrrec failed to establish synchronization with the
  856.             TOUT                                                       
  857.             sending program while waiting to receive the SOH (or STX for
  858.             YModem) character at the start of the block. The session is
  859.             automatically cancelled.
  860.  
  861.  
  862.             DUPSEQ - The block just received is a duplicate of the
  863.             DUPSEQ                                                
  864.             preceding block. The host program should ignore the data
  865.             contained within the block, the call lcxrrec to proceed with
  866.             data transfer.
  867.  
  868.  
  869.  
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  921.                                Datalight and Turbo C
  922.  
  923.            _______________________________________________________________
  924.  
  925.                                       lcxtrec
  926.            _______________________________________________________________
  927.  
  928.  
  929.             SUMMARY
  930.             SUMMARY
  931.             _______
  932.  
  933.                  #include <litexm.h>
  934.                  #include <litecomm.h>
  935.                  
  936.                  int lcxtrec(port, buff)
  937.                  
  938.                       unsigned port;
  939.                       unsigned char *buff;
  940.  
  941.  
  942.             DESCRIPTION
  943.             DESCRIPTION
  944.             ___________
  945.  
  946.             Transmit a block of 128 or 1024 bytes to the companion
  947.             system. The checking protocol, CRC or checksum, is detected
  948.             automatically when the receiving station issues its initial
  949.             handshaking sequence. If necessary, establish
  950.             synchronization with the companion system before
  951.             transmitting.
  952.  
  953.  
  954.             The port parameter is the same as used throughout the
  955.             LiteComm ToolBox.
  956.  
  957.  
  958.             Buff should be a pointer to a 128 or 1024 byte record to be
  959.             sent to the companion system. This is not a typical, null-
  960.             terminated string as usually found in C. All bytes, starting
  961.             at the pointer will be transmitted. It is the responsibility
  962.             of the host program to provide any padding that might be
  963.             required to satisfy the length requirement.  Generally,
  964.             short records are padded with NULLS or ^Z (0x1A).
  965.  
  966.  
  967.             Lcxtrec determines the block size to be transmitted based
  968.             upon the current value of the global variable ymodem (see
  969.             the introduction). If ymodem has a value of TRUE, then buff
  970.             is assumed to point to a 1024 byte record.  If ymodem is
  971.             FALSE, then a 128 byte record is assumed.  This feature has
  972.             particular value when operating in YModem mode.
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  992.                                Datalight and Turbo C
  993.  
  994.             When using YModem protocol, block sizes may be either 128 or
  995.             1024 bytes, at the senders discretion.  This serves two
  996.             purposes.  In the case of a large number of errors, many
  997.             YModem implementations will automatically switch to the
  998.             smaller block size if too many errors occur using the larger
  999.             block size, in an effort to get the data through, then
  1000.             revert back to the normal block of 1024 characters.  Lcxtrec
  1001.             implements this feature automatically.
  1002.  
  1003.  
  1004.             Generally, at the end of a file, the final block to be sent
  1005.             will not exactly match the transmission block size. Under
  1006.             XModem, this means that as many as 127 wasted characters
  1007.             might be transmitted.  Under YModem, as many as 1023 wasted
  1008.             characters can be transmitted in the final block.  However,
  1009.             the host program that calls lcxtrec can determine if the
  1010.             block to be sent is less than 1024 bytes, set the ymodem
  1011.             variable to FALSE, and send multiple 128 byte blocks.  Using
  1012.             this approach, the amount of wasted characters will be no
  1013.             worse than the original XModem.  The TTL sample program,
  1014.             included in the package, shows one way of approaching this
  1015.             problem.
  1016.  
  1017.  
  1018.  
  1019.             EXAMPLE
  1020.             EXAMPLE
  1021.             _______
  1022.  
  1023.             See the accompanying program TTL for an example of lcxtrec
  1024.             usage.
  1025.  
  1026.  
  1027.  
  1028.             RETURN VALUES
  1029.             RETURN VALUES
  1030.             _____________
  1031.  
  1032.             Lcxtrec may return several values, as defined in the
  1033.             litexm.h file. Each return value should cause the host
  1034.             program to respond in specific ways.
  1035.  
  1036.  
  1037.             SUCCESS - The record has been successfully sent from the
  1038.             SUCCESS                                                 
  1039.             buff area. Host program either calls lcxtrec with the next
  1040.             record to transmit, or lcxteot to indicate End of
  1041.             Transmission to the companion system.
  1042.  
  1043.  
  1044.             RETRIES - The maximum number of attempts to send a single
  1045.             RETRIES                                                  
  1046.             record has been exceeded. Lcxtrec automatically cancels the
  1047.             session. Host program should handle in an appropriate
  1048.             manner, e.g. issue an error message.
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  1064.                                Datalight and Turbo C
  1065.  
  1066.             ERR (-1) - Lcxtrec has detected that the host program has
  1067.             ERR                                                      
  1068.             requested cancellation of transmissions  through the
  1069.             _abort_flag setting (see below).
  1070.  
  1071.  
  1072.             CAN - The receiving program has requested cancellation.
  1073.             CAN                                                    
  1074.             Host program should handle in a fashion similar to RETRIES.
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130.  
  1131.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  1132.                                Datalight and Turbo C
  1133.  
  1134.            _______________________________________________________________
  1135.  
  1136.                                       lcxteot
  1137.            _______________________________________________________________
  1138.  
  1139.  
  1140.             SUMMARY
  1141.             SUMMARY
  1142.             _______
  1143.  
  1144.                  #include <litexm.h>
  1145.                  #include <litecomm.h>
  1146.                  
  1147.                  int lcxtrec(port)
  1148.                  
  1149.                       unsigned port;
  1150.  
  1151.  
  1152.             DESCRIPTION
  1153.             DESCRIPTION
  1154.             ___________
  1155.  
  1156.             Send and End of Transmission (End of File) to the receiving
  1157.             system. This function must be called to successfully close
  1158.             out the transmission session.
  1159.  
  1160.  
  1161.  
  1162.             EXAMPLE
  1163.             EXAMPLE
  1164.             _______
  1165.  
  1166.             See the accompanying program TTL for an example of lcxtrec
  1167.             usage.
  1168.  
  1169.  
  1170.  
  1171.             RETURN VALUES
  1172.             RETURN VALUES
  1173.             _____________
  1174.  
  1175.             Lcxteot returns one of two values, as defined in the
  1176.             litexm.h file.
  1177.  
  1178.             SUCCESS - The receiving station has correctly acknowledged
  1179.             SUCCESS                                                   
  1180.             the EOT. The host program terminates transmission mode
  1181.             normally.
  1182.  
  1183.             CAN - Either the receiving system has responded to the EOT
  1184.             CAN                                                       
  1185.             message with a CAN code, or has failed to respond correctly
  1186.             and the lcxteot function has sent the CAN code to the
  1187.             receiving system. Host program should handle in an
  1188.             appropriate manner, e.g. issue an appropriate error message.
  1189.  
  1190.  
  1191.             Regardless of the value returned, invoking lcxteot always
  1192.             terminates the current transmission session.
  1193.  
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205.